# build in python 3.5.2
# 作者：陈常鸿
# 伯努利分布下两个随机变量的交叉熵
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig=plt.figure()
ax=Axes3D(fig)
x=np.linspace(0.01,0.99,101)
y=np.linspace(0.01,0.99,101)
x,y=np.meshgrid(x,y)
z=-x*np.log2(y)-(1-x)*np.log2(1-y)
ax.plot_surface(x,y,z,rstride=1,cstride=1,cmap='rainbow')
plt.show()